package com.example.administrator.acmapp.Fragment;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ListView;

import android.widget.Toast;

import com.baoyz.widget.PullRefreshLayout;
import com.example.administrator.acmapp.Adapter.ClassRoomContentListViewAdapter;

import com.example.administrator.acmapp.Adapter.ClassRoomViewPageAdapter;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomEightFragment;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomElevenFragment;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomFiveFragment;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomNineFragment;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomOneFragment;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomSevenFragment;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomSixFragment;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomTenFragment;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomTreeFragment;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomTwoFragment;
import com.example.administrator.acmapp.Fragment.ClassroomFragmentPage.ClassRoomfourFragment;
import com.example.administrator.acmapp.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.support.design.widget.TabLayout;

/**
 * Created by Administrator on 2018/2/1/001.
 */

public class ClassroomFragment extends android.support.v4.app.Fragment {

    private View view;
    private ViewPager mContentViewPage;
    private ArrayList<Fragment> fragmentList;
    private GridView mNavGridView;
    private String[] mNavTitleNameArray;
    private List<Map> mNavNameList;
    private int mNavNameArrayLength;
    private ClassRoomOneFragment classRoomOneFragment;
    private ClassRoomTwoFragment classRoomTwoFragment;
    private TabLayout tabLayout;
    private ClassRoomTreeFragment classRoomTreeFragment;
    private ClassRoomfourFragment classRoomfourFragment;
    private ClassRoomFiveFragment classRoomFiveFragment;
    private ClassRoomSixFragment classRoomSixFragment;
    private ClassRoomSevenFragment classRoomSevenFragment;
    private ClassRoomEightFragment classRoomEightFragment;
    private ClassRoomNineFragment classRoomNineFragment;
    private ClassRoomTenFragment classRoomTenFragment;
    private ClassRoomElevenFragment classRoomElevenFragment;

    public ClassroomFragment() {

    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.classroom_fragment_layout, container, false);
        initNavTitleData();
        initNavView();
        initViewPageView();
        return view;
    }

    private void initNavTitleData() {
        mNavTitleNameArray = getResources().getStringArray(R.array.gridviewname);
    }

    private void initNavView() {
        tabLayout = view.findViewById(R.id.classroom_tablayout);

    }
    private void initViewPageView() {
        fragmentList = new ArrayList<>();
        classRoomOneFragment = new ClassRoomOneFragment();
        classRoomTwoFragment = new ClassRoomTwoFragment();
        classRoomTreeFragment = new ClassRoomTreeFragment();
        classRoomfourFragment = new ClassRoomfourFragment();
        classRoomFiveFragment = new ClassRoomFiveFragment();
        classRoomSixFragment = new ClassRoomSixFragment();
        classRoomSevenFragment = new ClassRoomSevenFragment();
        classRoomEightFragment = new ClassRoomEightFragment();
        classRoomNineFragment = new ClassRoomNineFragment();
        classRoomTenFragment = new ClassRoomTenFragment();
        classRoomElevenFragment = new ClassRoomElevenFragment();
        fragmentList.add(classRoomOneFragment);
        fragmentList.add(classRoomTwoFragment);
        fragmentList.add(classRoomTreeFragment);
        fragmentList.add(classRoomfourFragment);
        fragmentList.add(classRoomFiveFragment);
        fragmentList.add(classRoomSixFragment);
        fragmentList.add(classRoomSevenFragment);
        fragmentList.add(classRoomEightFragment);
        fragmentList.add(classRoomNineFragment);
        fragmentList.add(classRoomTenFragment);
        fragmentList.add(classRoomElevenFragment);
        mContentViewPage = view.findViewById(R.id.classroom_viewpage);
        ClassRoomViewPageAdapter classRoomViewPageAdapter = new ClassRoomViewPageAdapter(getFragmentManager());
        classRoomViewPageAdapter.setFragments(fragmentList,mNavTitleNameArray);
        mContentViewPage.setAdapter(classRoomViewPageAdapter);
        tabLayout.setupWithViewPager(mContentViewPage);
        tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    }
}
